/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package au.edu.swin.swinvehicle.corporateclient;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Administrator
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "findAllCorporateClients",
    query = "SELECT cc FROM CorporateClientEntity cc WHERE cc.deleted = false"),
    @NamedQuery(name = "findCorporateClientByUsername",
    query = "SELECT cc FROM CorporateClientEntity cc WHERE cc.username = :username AND cc.deleted = false")
})
@Table(name = "CORPORATECLIENT")
public class CorporateClientEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Column(nullable = false)
    private String username;
    @Column(nullable = false)
    private String password;
    @Column(length = 30, nullable = false)
    private String firstName;
    @Column(length = 30, nullable = false)
    private String lastName;
    @Column(length = 30, nullable = false)
    private String emailAddress;
    @Column(length = 20, nullable = false)
    private String contactNumber;
    @Column(length = 255, nullable = false)
    private String address;
    @Column(nullable = false)
    private Boolean deleted;

    public CorporateClientEntity() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    // Transfer Object Methods
    public CorporateClientTO getData() {
        return new CorporateClientTO(id, username, firstName, lastName);
    }

    public CorporateClientDetailedTO getDetailedData() {
        return new CorporateClientDetailedTO(id, username, password, firstName, lastName, emailAddress, contactNumber, address);
    }

    public void setData(CorporateClientDetailedTO to) {
        this.setUsername(to.getUsername());
        this.setPassword(to.getPassword());
        this.setFirstName(to.getFirstName());
        this.setLastName(to.getLastName());
        this.setEmailAddress(to.getEmailAddress());
        this.setContactNumber(to.getContactNumber());
        this.setAddress(to.getAddress());
    }

    public void setDetails(CorporateClientDetailedTO to) {
        this.setFirstName(to.getFirstName());
        this.setLastName(to.getLastName());
        this.setEmailAddress(to.getEmailAddress());
        this.setContactNumber(to.getContactNumber());
        this.setAddress(to.getAddress());
    }

    @Override
    public String toString() {
        return "au.edu.swin.swinvehicle.corporateclient.CorporateClientEntity[id=" + id + "]";
    }
}
